package com.svse.designPattern.dependenceinversionprinciple;

import com.svse.designPattern.dependenceinversionprinciple.impl.EmailMessage;
import com.svse.designPattern.dependenceinversionprinciple.impl.VxMessage;
import com.svse.designPattern.dependenceinversionprinciple.service.Message;

/**
 * @author LiYuhang
 * @version 0.1
 * @application
 * @Date 2020/7/25 17:32
 */
public class DITest {

    public static void main(String[] args) {
        Person person = new Person();
        person.receiveVxMessage();
        person.receiveEmailMessage();
        person.receiveMessage(new EmailMessage());
        person.receiveMessage(new VxMessage());
    }
}

/**
 * 面向接口编程  不要面向实现编程
 */


/**
 * 人 接收消息
 */
class Person{
    public void receiveEmailMessage(){
        System.out.println("receiveEmailMessage");
    }

    public void receiveVxMessage(){
        System.out.println("receiveVxMessage");
    }
    void receiveMessage(Message message){
        message.receiveMessage();
    }
}


